package com.zm.demo.webservice.server;

import com.zm.demo.webservice.server.impl.HelloServiceImpl;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import javax.xml.ws.Endpoint;

public class Server {

    protected Server() throws Exception {
        // START SNIPPET: publish
        System.out.println("Starting Server");
        HelloService implementor = new HelloServiceImpl();
        String address = "http://localhost:9000/helloWorld";
        Endpoint.publish(address, implementor, new LoggingFeature());
        // END SNIPPET: publish
    }

    public static void main(String[] args) throws Exception {
        new Server();
        System.out.println("Server ready...");

        Thread.sleep(30 * 60 * 1000);
        System.out.println("Server exiting");
        System.exit(0);

//        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
//        factory.setServiceClass(HelloService.class);
//        factory.setAddress("http://localhost:8082/helloworld");
//        factory.create().start();
    }
}